package 多线程;

import com.sun.org.slf4j.internal.Logger;
import com.sun.org.slf4j.internal.LoggerFactory;

public class TestThread extends Thread{

    private String name;

    public TestThread() {
    }

    public TestThread(String name) {
        super(name);
        this.name = name;
    }

    @Override
    public void run() {
        synchronized (Entity.class){
            System.out.printf("%s 线程开启\n-------------------------------------\n",name);

            for (int i = 0; i < 1000; i++) {
                Entity.num += 1;

                System.out.printf("[%s]线程 将 Entity.num 加一 = [\t%d\t]\n",name,Entity.num);
                try {
                    Thread.sleep(2);
                } catch (InterruptedException e) {
                    throw new RuntimeException(e);
                }
            }

            System.out.printf("%s 线程关闭\n--------------------------------------\n",name);
        }
    }
}
